From 04250df04652b746cf77e87aa52e4048d06e4062 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Wed, 3 Sep 2008 11:02:57 +0100 Subject: [PATCH] Fix for VCPU periodic timer. Idle vcpu periodic timer is useless. It increased the lapic timer interrupt number, which decreased the cpu idle residency. This patch disables idle vcpu periodic timer via keeping v->periodic_period = 0. The vcpu periodic timer may be expired 50us before expected time because there is a 50us TIMER_SLOP used for soft timer (xen/common/timer.c, timer_softirq_action()). This will cause vcpu_periodic_timer_work() be continuously called tens of times in a single call of timer_softirq_action() until (now > periodic_next_event). It brings unnecessary overhead. This patch adds a similar time slop in vcpu periodic timer to eliminate this overhead. Signed-off-by: Wei Gang --- xen/arch/x86/domain.c | 3 ++- xen/common/schedule.c | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 1dc24924e6..10d0cef7c6 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -302,7 +302,8 @@ int vcpu_initialise(struct vcpu *v) else { /* PV guests by default have a 100Hz ticker. */ - v->periodic_period = MILLISECS(10); + if ( !is_idle_domain(d) ) + v->periodic_period = MILLISECS(10); /* PV guests get an emulated PIT too for video BIOSes to use. */ if ( !is_idle_domain(d) && (v->vcpu_id == 0) ) diff --git a/xen/common/schedule.c b/xen/common/schedule.c index 2934d07029..7d32c99485 100644 --- a/xen/common/schedule.c +++ b/xen/common/schedule.c @@ -628,7 +628,9 @@ static void vcpu_periodic_timer_work(struct vcpu *v) return; periodic_next_event = v->periodic_last_event + v->periodic_period; - if ( now > periodic_next_event ) + + /* The timer subsystem may call us up to TIME_SLOP ahead of deadline. */ + if ( (now + TIME_SLOP) > periodic_next_event ) { send_timer_event(v); v->periodic_last_event = now; -- 2.30.2